﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CSharp1.Core
{
    public class Person
    {
        private string name;
        private string sex;
        private int height;
        private int weight = -100;

        private int step = 0;

        public void SetName(string name)
        {
            if (step != 0)
            {
                MessageBox.Show("请不要重复给我设置名字");
            }
            if (name != null)
            {
                this.name = name;
                step++;
            }
        }

        public void Hello()
        {
            if (weight == -100)
            {
                MessageBox.Show("请先调用SetWeight方法给我设置体重吧");
            }
            else
            {
                string info = string.Format("你好我是：{0}\n", name);
                info += string.Format("性别：{0}\n", sex);
                info += string.Format("身高：{0}\n", height);
                info += string.Format("体重：{0}\n", weight);
                MessageBox.Show(info);
            }
        }

        public void SetSex(string sex)
        {
            if (step != 1)
            {
                MessageBox.Show("您只能在设置名字(SetName)后马上来调用我!");
                return;
            }
            this.sex = sex;
            step++;
        }
        public void SetHeight(int h)
        {
            if (step != 2)
            {
                MessageBox.Show("您只能在设置性别(SetSex)后马上来调用我!");
                return;
            }
            this.height = h;
            step++;
        }
        public void SetWeight(int w)
        {
            if (step != 3)
            {
                MessageBox.Show("您只能在设置身高(SetHeight)后马上来调用我!");
                return;
            }
            this.weight = w;
            step++;
        }
    }
}
